<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>pytils.translit</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="pytils-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="pytils-module.html">Package&nbsp;pytils</a> ::
        Module&nbsp;translit
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript: void(0);" class="privatelink"
    onclick="toggle_private();">hide private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="pytils.translit-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="pytils.translit-module.html">Module pytils.translit</a></h1>
<pre class="py-src">
<span class="py-lineno">  1</span>  <span class="py-line"><span class="py-comment"># -*- coding: utf-8 -*-</span> </span>
<span class="py-lineno">  2</span>  <span class="py-line"><span class="py-comment"></span><span class="py-comment"># -*- test-case-name: pytils.test.test_translit -*-</span> </span>
<span class="py-lineno">  3</span>  <span class="py-line"><span class="py-comment"></span><span class="py-comment"># License: GNU GPL2</span> </span>
<span class="py-lineno">  4</span>  <span class="py-line"><span class="py-comment"></span><span class="py-comment"># Author: Pythy &lt;the.pythy@gmail.com&gt;</span> </span>
<span class="py-lineno">  5</span>  <span class="py-line"><span class="py-comment"></span><span class="py-docstring">"""</span> </span>
<span class="py-lineno">  6</span>  <span class="py-line"><span class="py-docstring">Simple transliteration</span> </span>
<span class="py-lineno">  7</span>  <span class="py-line"><span class="py-docstring">"""</span> </span>
<span class="py-lineno">  8</span>  <span class="py-line"> </span>
<span class="py-lineno">  9</span>  <span class="py-line"><span id="link-0" class="py-name"><a title="pytils.__id__
pytils.dt.__id__
pytils.numeral.__id__
pytils.templatetags.__id__
pytils.templatetags.pytils_dt.__id__
pytils.templatetags.pytils_numeral.__id__
pytils.templatetags.pytils_translit.__id__
pytils.test.__id__
pytils.test.test_dt.__id__
pytils.test.test_numeral.__id__
pytils.test.test_translit.__id__
pytils.test.test_utils.__id__
pytils.translit.__id__
pytils.utils.__id__" class="py-name" href="#" onclick="doclink('link-0', '__id__', 'Variable pytils.__id__=pytils-module.html#__id__,Variable pytils.dt.__id__=pytils.dt-module.html#__id__,Variable pytils.numeral.__id__=pytils.numeral-module.html#__id__,Variable pytils.templatetags.__id__=pytils.templatetags-module.html#__id__,Variable pytils.templatetags.pytils_dt.__id__=pytils.templatetags.pytils_dt-module.html#__id__,Variable pytils.templatetags.pytils_numeral.__id__=pytils.templatetags.pytils_numeral-module.html#__id__,Variable pytils.templatetags.pytils_translit.__id__=pytils.templatetags.pytils_translit-module.html#__id__,Variable pytils.test.__id__=pytils.test-module.html#__id__,Variable pytils.test.test_dt.__id__=pytils.test.test_dt-module.html#__id__,Variable pytils.test.test_numeral.__id__=pytils.test.test_numeral-module.html#__id__,Variable pytils.test.test_translit.__id__=pytils.test.test_translit-module.html#__id__,Variable pytils.test.test_utils.__id__=pytils.test.test_utils-module.html#__id__,Variable pytils.translit.__id__=pytils.translit-module.html#__id__,Variable pytils.utils.__id__=pytils.utils-module.html#__id__'); return false;">__id__</a></span></span> <span class="py-op">=</span> <span id="link-1" class="py-name"><a title="pytils.__revision__
pytils.dt.__revision__
pytils.numeral.__revision__
pytils.templatetags.__revision__
pytils.templatetags.pytils_dt.__revision__
pytils.templatetags.pytils_numeral.__revision__
pytils.templatetags.pytils_translit.__revision__
pytils.test.__revision__
pytils.test.test_dt.__revision__
pytils.test.test_numeral.__revision__
pytils.test.test_translit.__revision__
pytils.test.test_utils.__revision__
pytils.translit.__revision__
pytils.utils.__revision__" class="py-name" href="#" onclick="doclink('link-1', '__revision__', 'Variable pytils.__revision__=pytils-module.html#__revision__,Variable pytils.dt.__revision__=pytils.dt-module.html#__revision__,Variable pytils.numeral.__revision__=pytils.numeral-module.html#__revision__,Variable pytils.templatetags.__revision__=pytils.templatetags-module.html#__revision__,Variable pytils.templatetags.pytils_dt.__revision__=pytils.templatetags.pytils_dt-module.html#__revision__,Variable pytils.templatetags.pytils_numeral.__revision__=pytils.templatetags.pytils_numeral-module.html#__revision__,Variable pytils.templatetags.pytils_translit.__revision__=pytils.templatetags.pytils_translit-module.html#__revision__,Variable pytils.test.__revision__=pytils.test-module.html#__revision__,Variable pytils.test.test_dt.__revision__=pytils.test.test_dt-module.html#__revision__,Variable pytils.test.test_numeral.__revision__=pytils.test.test_numeral-module.html#__revision__,Variable pytils.test.test_translit.__revision__=pytils.test.test_translit-module.html#__revision__,Variable pytils.test.test_utils.__revision__=pytils.test.test_utils-module.html#__revision__,Variable pytils.translit.__revision__=pytils.translit-module.html#__revision__,Variable pytils.utils.__revision__=pytils.utils-module.html#__revision__'); return false;">__revision__</a></span></span> <span class="py-op">=</span> <span class="py-string">"$Id: translit.py 32 2006-10-28 07:10:43Z the.pythy $"</span> </span>
<span class="py-lineno"> 10</span>  <span class="py-line"><span id="link-2" class="py-name"><a title="pytils.__url__
pytils.dt.__url__
pytils.numeral.__url__
pytils.templatetags.__url__
pytils.templatetags.pytils_dt.__url__
pytils.templatetags.pytils_numeral.__url__
pytils.templatetags.pytils_translit.__url__
pytils.test.__url__
pytils.test.test_dt.__url__
pytils.test.test_numeral.__url__
pytils.test.test_translit.__url__
pytils.test.test_utils.__url__
pytils.translit.__url__
pytils.utils.__url__" class="py-name" href="#" onclick="doclink('link-2', '__url__', 'Variable pytils.__url__=pytils-module.html#__url__,Variable pytils.dt.__url__=pytils.dt-module.html#__url__,Variable pytils.numeral.__url__=pytils.numeral-module.html#__url__,Variable pytils.templatetags.__url__=pytils.templatetags-module.html#__url__,Variable pytils.templatetags.pytils_dt.__url__=pytils.templatetags.pytils_dt-module.html#__url__,Variable pytils.templatetags.pytils_numeral.__url__=pytils.templatetags.pytils_numeral-module.html#__url__,Variable pytils.templatetags.pytils_translit.__url__=pytils.templatetags.pytils_translit-module.html#__url__,Variable pytils.test.__url__=pytils.test-module.html#__url__,Variable pytils.test.test_dt.__url__=pytils.test.test_dt-module.html#__url__,Variable pytils.test.test_numeral.__url__=pytils.test.test_numeral-module.html#__url__,Variable pytils.test.test_translit.__url__=pytils.test.test_translit-module.html#__url__,Variable pytils.test.test_utils.__url__=pytils.test.test_utils-module.html#__url__,Variable pytils.translit.__url__=pytils.translit-module.html#__url__,Variable pytils.utils.__url__=pytils.utils-module.html#__url__'); return false;">__url__</a></span></span> <span class="py-op">=</span> <span class="py-string">"$URL: https://pythy.googlecode.com/svn/trunk/pytils/pytils/translit.py $"</span> </span>
<span class="py-lineno"> 11</span>  <span class="py-line"> </span>
<span class="py-lineno"> 12</span>  <span class="py-line"><span class="py-keyword">import</span> <span class="py-name">re</span> </span>
<span class="py-lineno"> 13</span>  <span class="py-line"><span class="py-keyword">from</span> <span id="link-3" class="py-name"><a title="pytils" class="py-name" href="#" onclick="doclink('link-3', 'pytils', 'Package pytils=pytils-module.html'); return false;">pytils</a></span></span> <span class="py-keyword">import</span> <span id="link-4" class="py-name"><a title="pytils.utils" class="py-name" href="#" onclick="doclink('link-4', 'utils', 'Module pytils.utils=pytils.utils-module.html'); return false;">utils</a></span></span> </span>
<span class="py-lineno"> 14</span>  <span class="py-line"> </span>
<span class="py-lineno"> 15</span>  <span class="py-line"><span id="link-5" class="py-name"><a title="pytils.translit.TRANSTABLE" class="py-name" href="#" onclick="doclink('link-5', 'TRANSTABLE', 'Variable pytils.translit.TRANSTABLE=pytils.translit-module.html#TRANSTABLE'); return false;">TRANSTABLE</a></span></span> <span class="py-op">=</span> <span class="py-op">(</span> </span>
<span class="py-lineno"> 16</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#8216;"</span><span class="py-op">,</span> <span class="py-string">u"'"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 17</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#8217;"</span><span class="py-op">,</span> <span class="py-string">u"'"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 18</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#171;"</span><span class="py-op">,</span> <span class="py-string">u'"'</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 19</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#187;"</span><span class="py-op">,</span> <span class="py-string">u'"'</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 20</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#8211;"</span><span class="py-op">,</span> <span class="py-string">u"-"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 21</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#8230;"</span><span class="py-op">,</span> <span class="py-string">u"..."</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 22</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#8470;"</span><span class="py-op">,</span> <span class="py-string">u"#"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 23</span>  <span class="py-line">        <span class="py-comment">## &#1074;&#1077;&#1088;&#1093;&#1085;&#1080;&#1081; &#1088;&#1077;&#1075;&#1080;&#1089;&#1090;&#1088;</span> </span>
<span class="py-lineno"> 24</span>  <span class="py-line">        <span class="py-comment"># &#1090;&#1088;&#1077;&#1093;&#1073;&#1091;&#1082;&#1074;&#1077;&#1085;&#1085;&#1099;&#1077; &#1079;&#1072;&#1084;&#1077;&#1085;&#1099;</span> </span>
<span class="py-lineno"> 25</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1065;"</span><span class="py-op">,</span> <span class="py-string">u"Sch"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 26</span>  <span class="py-line">        <span class="py-comment"># &#1087;&#1088;&#1080; &#1079;&#1072;&#1084;&#1077;&#1085;&#1077; &#1088;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;-&gt;&#1072;&#1085;&#1075;&#1083;&#1080;&#1081;&#1089;&#1082;&#1080;&#1081; &#1073;&#1091;&#1076;&#1077;&#1090; &#1087;&#1077;&#1088;&#1074;&#1072;&#1103; &#1079;&#1072;&#1084;&#1077;&#1085;&#1072;,</span> </span>
<span class="py-lineno"> 27</span>  <span class="py-line">        <span class="py-comment"># &#1090;.&#1077;. Sch</span> </span>
<span class="py-lineno"> 28</span>  <span class="py-line">        <span class="py-comment"># &#1072; &#1074;&#1086;&#1090; &#1077;&#1089;&#1083;&#1080; &#1072;&#1085;&#1075;&#1083;&#1080;&#1081;&#1089;&#1082;&#1080;&#1081;-&gt;&#1088;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;, &#1090;&#1086; &#1074;&#1072;&#1088;&#1080;&#1072;&#1085;&#1090; SCH &#1080; Sch --</span> </span>
<span class="py-lineno"> 29</span>  <span class="py-line">        <span class="py-comment"># &#1086;&#1073;&#1072; &#1087;&#1088;&#1086;&#1081;&#1076;&#1091;&#1090;</span> </span>
<span class="py-lineno"> 30</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1065;"</span><span class="py-op">,</span> <span class="py-string">u"SCH"</span><span class="py-op">)</span><span class="py-op">,</span>  </span>
<span class="py-lineno"> 31</span>  <span class="py-line">        <span class="py-comment"># &#1076;&#1074;&#1091;&#1093;&#1073;&#1091;&#1082;&#1074;&#1077;&#1085;&#1085;&#1099;&#1077; &#1079;&#1072;&#1084;&#1077;&#1085;&#1099;</span> </span>
<span class="py-lineno"> 32</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1025;"</span><span class="py-op">,</span> <span class="py-string">u"Yo"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 33</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1025;"</span><span class="py-op">,</span> <span class="py-string">u"YO"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 34</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1046;"</span><span class="py-op">,</span> <span class="py-string">u"Zh"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 35</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1046;"</span><span class="py-op">,</span> <span class="py-string">u"ZH"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 36</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1062;"</span><span class="py-op">,</span> <span class="py-string">u"Ts"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 37</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1062;"</span><span class="py-op">,</span> <span class="py-string">u"TS"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 38</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1063;"</span><span class="py-op">,</span> <span class="py-string">u"Ch"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 39</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1063;"</span><span class="py-op">,</span> <span class="py-string">u"CH"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 40</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1064;"</span><span class="py-op">,</span> <span class="py-string">u"Sh"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 41</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1064;"</span><span class="py-op">,</span> <span class="py-string">u"SH"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 42</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1067;"</span><span class="py-op">,</span> <span class="py-string">u"Yi"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 43</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1067;"</span><span class="py-op">,</span> <span class="py-string">u"YI"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 44</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1070;"</span><span class="py-op">,</span> <span class="py-string">u"Yu"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 45</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1070;"</span><span class="py-op">,</span> <span class="py-string">u"YU"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 46</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1071;"</span><span class="py-op">,</span> <span class="py-string">u"Ya"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 47</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1071;"</span><span class="py-op">,</span> <span class="py-string">u"YA"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 48</span>  <span class="py-line">        <span class="py-comment"># &#1086;&#1076;&#1085;&#1086;&#1073;&#1091;&#1082;&#1074;&#1077;&#1085;&#1085;&#1099;&#1077; &#1079;&#1072;&#1084;&#1077;&#1085;&#1099;</span> </span>
<span class="py-lineno"> 49</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1040;"</span><span class="py-op">,</span> <span class="py-string">u"A"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 50</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1041;"</span><span class="py-op">,</span> <span class="py-string">u"B"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 51</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1042;"</span><span class="py-op">,</span> <span class="py-string">u"V"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 52</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1043;"</span><span class="py-op">,</span> <span class="py-string">u"G"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 53</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1044;"</span><span class="py-op">,</span> <span class="py-string">u"D"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 54</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1045;"</span><span class="py-op">,</span> <span class="py-string">u"E"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 55</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1047;"</span><span class="py-op">,</span> <span class="py-string">u"Z"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 56</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1048;"</span><span class="py-op">,</span> <span class="py-string">u"I"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 57</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1049;"</span><span class="py-op">,</span> <span class="py-string">u"J"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 58</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1050;"</span><span class="py-op">,</span> <span class="py-string">u"K"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 59</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1051;"</span><span class="py-op">,</span> <span class="py-string">u"L"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 60</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1052;"</span><span class="py-op">,</span> <span class="py-string">u"M"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 61</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1053;"</span><span class="py-op">,</span> <span class="py-string">u"N"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 62</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1054;"</span><span class="py-op">,</span> <span class="py-string">u"O"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 63</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1055;"</span><span class="py-op">,</span> <span class="py-string">u"P"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 64</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1056;"</span><span class="py-op">,</span> <span class="py-string">u"R"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 65</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1057;"</span><span class="py-op">,</span> <span class="py-string">u"S"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 66</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1058;"</span><span class="py-op">,</span> <span class="py-string">u"T"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 67</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1059;"</span><span class="py-op">,</span> <span class="py-string">u"U"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 68</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1060;"</span><span class="py-op">,</span> <span class="py-string">u"F"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 69</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1061;"</span><span class="py-op">,</span> <span class="py-string">u"H"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 70</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1069;"</span><span class="py-op">,</span> <span class="py-string">u"E"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 71</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1066;"</span><span class="py-op">,</span> <span class="py-string">u"`"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 72</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1068;"</span><span class="py-op">,</span> <span class="py-string">u"'"</span><span class="py-op">)</span><span class="py-op">,</span>         </span>
<span class="py-lineno"> 73</span>  <span class="py-line">        <span class="py-comment">## &#1085;&#1080;&#1078;&#1085;&#1080;&#1081; &#1088;&#1077;&#1075;&#1080;&#1089;&#1090;&#1088;</span> </span>
<span class="py-lineno"> 74</span>  <span class="py-line">        <span class="py-comment"># &#1090;&#1088;&#1077;&#1093;&#1073;&#1091;&#1082;&#1074;&#1077;&#1085;&#1085;&#1099;&#1077; &#1079;&#1072;&#1084;&#1077;&#1085;&#1099;</span> </span>
<span class="py-lineno"> 75</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1097;"</span><span class="py-op">,</span> <span class="py-string">u"sch"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 76</span>  <span class="py-line">        <span class="py-comment"># &#1076;&#1074;&#1091;&#1093;&#1073;&#1091;&#1082;&#1074;&#1077;&#1085;&#1085;&#1099;&#1077; &#1079;&#1072;&#1084;&#1077;&#1085;&#1099;</span> </span>
<span class="py-lineno"> 77</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1105;"</span><span class="py-op">,</span> <span class="py-string">u"yo"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 78</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1078;"</span><span class="py-op">,</span> <span class="py-string">u"zh"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 79</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1094;"</span><span class="py-op">,</span> <span class="py-string">u"ts"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 80</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1095;"</span><span class="py-op">,</span> <span class="py-string">u"ch"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 81</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1096;"</span><span class="py-op">,</span> <span class="py-string">u"sh"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 82</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1099;"</span><span class="py-op">,</span> <span class="py-string">u"yi"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 83</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1102;"</span><span class="py-op">,</span> <span class="py-string">u"yu"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 84</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1103;"</span><span class="py-op">,</span> <span class="py-string">u"ya"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 85</span>  <span class="py-line">        <span class="py-comment"># &#1086;&#1076;&#1085;&#1086;&#1073;&#1091;&#1082;&#1074;&#1077;&#1085;&#1085;&#1099;&#1077; &#1079;&#1072;&#1084;&#1077;&#1085;&#1099;</span> </span>
<span class="py-lineno"> 86</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1072;"</span><span class="py-op">,</span> <span class="py-string">u"a"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 87</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1073;"</span><span class="py-op">,</span> <span class="py-string">u"b"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 88</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1074;"</span><span class="py-op">,</span> <span class="py-string">u"v"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 89</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1075;"</span><span class="py-op">,</span> <span class="py-string">u"g"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 90</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1076;"</span><span class="py-op">,</span> <span class="py-string">u"d"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 91</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1077;"</span><span class="py-op">,</span> <span class="py-string">u"e"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 92</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1079;"</span><span class="py-op">,</span> <span class="py-string">u"z"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 93</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1080;"</span><span class="py-op">,</span> <span class="py-string">u"i"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 94</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1081;"</span><span class="py-op">,</span> <span class="py-string">u"j"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 95</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1082;"</span><span class="py-op">,</span> <span class="py-string">u"k"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 96</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1083;"</span><span class="py-op">,</span> <span class="py-string">u"l"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 97</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1084;"</span><span class="py-op">,</span> <span class="py-string">u"m"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 98</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1085;"</span><span class="py-op">,</span> <span class="py-string">u"n"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno"> 99</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1086;"</span><span class="py-op">,</span> <span class="py-string">u"o"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">100</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1087;"</span><span class="py-op">,</span> <span class="py-string">u"p"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">101</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1088;"</span><span class="py-op">,</span> <span class="py-string">u"r"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">102</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1089;"</span><span class="py-op">,</span> <span class="py-string">u"s"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">103</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1090;"</span><span class="py-op">,</span> <span class="py-string">u"t"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">104</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1091;"</span><span class="py-op">,</span> <span class="py-string">u"u"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">105</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1092;"</span><span class="py-op">,</span> <span class="py-string">u"f"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">106</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1093;"</span><span class="py-op">,</span> <span class="py-string">u"h"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">107</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1101;"</span><span class="py-op">,</span> <span class="py-string">u"e"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">108</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1098;"</span><span class="py-op">,</span> <span class="py-string">u"`"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">109</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"&#1100;"</span><span class="py-op">,</span> <span class="py-string">u"'"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">110</span>  <span class="py-line">        <span class="py-comment"># &#1076;&#1083;&#1103; &#1087;&#1086;&#1083;&#1085;&#1086;&#1090;&#1099; &#1072;&#1085;&#1075;&#1083;&#1080;&#1081;&#1089;&#1082;&#1086;&#1075;&#1086; &#1072;&#1083;&#1092;&#1072;&#1074;&#1080;&#1090; (&#1074; slugify)</span> </span>
<span class="py-lineno">111</span>  <span class="py-line">        <span class="py-comment"># &#1076;&#1086;&#1087;&#1086;&#1083;&#1085;&#1103;&#1077;&#1084; &#1072;&#1085;&#1075;&#1083;&#1080;&#1081;&#1089;&#1082;&#1080;&#1084;&#1080; &#1073;&#1091;&#1082;&#1074;&#1072;&#1084;&#1080;, &#1082;&#1086;&#1090;&#1086;&#1088;&#1099;&#1093;</span> </span>
<span class="py-lineno">112</span>  <span class="py-line">        <span class="py-comment"># &#1085;&#1077; &#1074; &#1087;&#1072;&#1088;&#1072;&#1093;</span> </span>
<span class="py-lineno">113</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"c"</span><span class="py-op">,</span> <span class="py-string">u"c"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">114</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"q"</span><span class="py-op">,</span> <span class="py-string">u"q"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">115</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"y"</span><span class="py-op">,</span> <span class="py-string">u"y"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">116</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"x"</span><span class="py-op">,</span> <span class="py-string">u"x"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">117</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"C"</span><span class="py-op">,</span> <span class="py-string">u"C"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">118</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"Q"</span><span class="py-op">,</span> <span class="py-string">u"Q"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">119</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"Y"</span><span class="py-op">,</span> <span class="py-string">u"Y"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">120</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"X"</span><span class="py-op">,</span> <span class="py-string">u"X"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">121</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"1"</span><span class="py-op">,</span> <span class="py-string">u"1"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">122</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"2"</span><span class="py-op">,</span> <span class="py-string">u"2"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">123</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"3"</span><span class="py-op">,</span> <span class="py-string">u"3"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">124</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"4"</span><span class="py-op">,</span> <span class="py-string">u"4"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">125</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"5"</span><span class="py-op">,</span> <span class="py-string">u"5"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">126</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"6"</span><span class="py-op">,</span> <span class="py-string">u"6"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">127</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"7"</span><span class="py-op">,</span> <span class="py-string">u"7"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">128</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"8"</span><span class="py-op">,</span> <span class="py-string">u"8"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">129</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"9"</span><span class="py-op">,</span> <span class="py-string">u"9"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">130</span>  <span class="py-line">        <span class="py-op">(</span><span class="py-string">u"0"</span><span class="py-op">,</span> <span class="py-string">u"0"</span><span class="py-op">)</span><span class="py-op">,</span> </span>
<span class="py-lineno">131</span>  <span class="py-line">        <span class="py-op">)</span>  <span class="py-comment">#: Translation table</span> </span>
<span class="py-lineno">132</span>  <span class="py-line"> </span>
<span class="py-lineno">133</span>  <span class="py-line"><span id="link-6" class="py-name"><a title="pytils.translit.RU_ALPHABET" class="py-name" href="#" onclick="doclink('link-6', 'RU_ALPHABET', 'Variable pytils.translit.RU_ALPHABET=pytils.translit-module.html#RU_ALPHABET'); return false;">RU_ALPHABET</a></span></span> <span class="py-op">=</span> <span class="py-op">[</span><span id="link-7" class="py-name"><a title="pytils.translit.x" class="py-name" href="#" onclick="doclink('link-7', 'x', 'Variable pytils.translit.x=pytils.translit-module.html#x'); return false;">x</a></span></span><span class="py-op">[</span><span class="py-number">0</span><span class="py-op">]</span> <span class="py-keyword">for</span> <span id="link-8" class="py-name"><a title="pytils.translit.x" class="py-name" href="#" onclick="doclink('link-8', 'x', 'Variable pytils.translit.x=pytils.translit-module.html#x'); return false;">x</a></span></span> <span class="py-keyword">in</span> <span id="link-9" class="py-name"><a title="pytils.translit.TRANSTABLE" class="py-name" href="#" onclick="doclink('link-9', 'TRANSTABLE', 'Variable pytils.translit.TRANSTABLE=pytils.translit-module.html#TRANSTABLE'); return false;">TRANSTABLE</a></span></span><span class="py-op">]</span> <span class="py-comment">#: Russian alphabet that we can translate</span> </span>
<span class="py-lineno">134</span>  <span class="py-line"><span id="link-10" class="py-name"><a title="pytils.translit.EN_ALPHABET" class="py-name" href="#" onclick="doclink('link-10', 'EN_ALPHABET', 'Variable pytils.translit.EN_ALPHABET=pytils.translit-module.html#EN_ALPHABET'); return false;">EN_ALPHABET</a></span></span> <span class="py-op">=</span> <span class="py-op">[</span><span id="link-11" class="py-name"><a title="pytils.translit.x" class="py-name" href="#" onclick="doclink('link-11', 'x', 'Variable pytils.translit.x=pytils.translit-module.html#x'); return false;">x</a></span></span><span class="py-op">[</span><span class="py-number">1</span><span class="py-op">]</span> <span class="py-keyword">for</span> <span id="link-12" class="py-name"><a title="pytils.translit.x" class="py-name" href="#" onclick="doclink('link-12', 'x', 'Variable pytils.translit.x=pytils.translit-module.html#x'); return false;">x</a></span></span> <span class="py-keyword">in</span> <span id="link-13" class="py-name"><a title="pytils.translit.TRANSTABLE" class="py-name" href="#" onclick="doclink('link-13', 'TRANSTABLE', 'Variable pytils.translit.TRANSTABLE=pytils.translit-module.html#TRANSTABLE'); return false;">TRANSTABLE</a></span></span><span class="py-op">]</span> <span class="py-comment">#: English alphabet that we can detransliterate</span> </span>
<span class="py-lineno">135</span>  <span class="py-line"><span id="link-14" class="py-name"><a title="pytils.translit.ALPHABET" class="py-name" href="#" onclick="doclink('link-14', 'ALPHABET', 'Variable pytils.translit.ALPHABET=pytils.translit-module.html#ALPHABET'); return false;">ALPHABET</a></span></span> <span class="py-op">=</span> <span id="link-15" class="py-name"><a title="pytils.translit.RU_ALPHABET" class="py-name" href="#" onclick="doclink('link-15', 'RU_ALPHABET', 'Variable pytils.translit.RU_ALPHABET=pytils.translit-module.html#RU_ALPHABET'); return false;">RU_ALPHABET</a></span></span> <span class="py-op">+</span> <span id="link-16" class="py-name"><a title="pytils.translit.EN_ALPHABET" class="py-name" href="#" onclick="doclink('link-16', 'EN_ALPHABET', 'Variable pytils.translit.EN_ALPHABET=pytils.translit-module.html#EN_ALPHABET'); return false;">EN_ALPHABET</a></span></span> <span class="py-comment">#: Alphabet that we can (de)transliterate</span> </span>
<span class="py-lineno">136</span>  <span class="py-line"> </span>
<span class="py-lineno">137</span>  <span class="py-line"> </span>
<a name="translify"></a><div id="translify-def"><span class="py-lineno">138</span> <a class="py-toggle" href="#" id="translify-toggle" onclick="toggle('translify'); return false;">-</a><span class="py-line"><span class="py-keyword">def</span> <a class="py-def-name" href="pytils.translit-module.html#translify">translify</a><span class="py-op">(</span><span class="py-param">in_string</span><span class="py-op">)</span><span class="py-op">:</span> </span>
</div><div id="translify-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="translify-expanded"><span class="py-lineno">139</span>  <span class="py-line">    <span class="py-docstring">"""</span> </span>
<span class="py-lineno">140</span>  <span class="py-line"><span class="py-docstring">    Translify russian text</span> </span>
<span class="py-lineno">141</span>  <span class="py-line"><span class="py-docstring"></span> </span>
<span class="py-lineno">142</span>  <span class="py-line"><span class="py-docstring">    @param in_string: input string</span> </span>
<span class="py-lineno">143</span>  <span class="py-line"><span class="py-docstring">    @type in_string: C{unicode}</span> </span>
<span class="py-lineno">144</span>  <span class="py-line"><span class="py-docstring">    </span> </span>
<span class="py-lineno">145</span>  <span class="py-line"><span class="py-docstring">    @return: transliterated string</span> </span>
<span class="py-lineno">146</span>  <span class="py-line"><span class="py-docstring">    @rtype: C{str}</span> </span>
<span class="py-lineno">147</span>  <span class="py-line"><span class="py-docstring"></span> </span>
<span class="py-lineno">148</span>  <span class="py-line"><span class="py-docstring">    @raise TypeError: when in_string is not C{unicode}</span> </span>
<span class="py-lineno">149</span>  <span class="py-line"><span class="py-docstring">    @raise ValueError: when string doesn't transliterate completely</span> </span>
<span class="py-lineno">150</span>  <span class="py-line"><span class="py-docstring">    """</span> </span>
<span class="py-lineno">151</span>  <span class="py-line">    <span id="link-17" class="py-name"><a title="pytils.utils" class="py-name" href="#" onclick="doclink('link-17', 'utils', 'Module pytils.utils=pytils.utils-module.html'); return false;">utils</a></span></span><span class="py-op">.</span><span id="link-18" class="py-name"><a title="pytils.utils.check_type" class="py-name" href="#" onclick="doclink('link-18', 'check_type', 'Function pytils.utils.check_type()=pytils.utils-module.html#check_type'); return false;">check_type</a></span></span><span class="py-op">(</span><span class="py-string">'in_string'</span><span class="py-op">,</span> <span class="py-name">unicode</span><span class="py-op">)</span> </span>
<span class="py-lineno">152</span>  <span class="py-line"> </span>
<span class="py-lineno">153</span>  <span class="py-line">    <span id="link-19" class="py-name"><a title="pytils.translit" class="py-name" href="#" onclick="doclink('link-19', 'translit', 'Module pytils.translit=pytils.translit-module.html'); return false;">translit</a></span></span> <span class="py-op">=</span> <span class="py-name">in_string</span> </span>
<span class="py-lineno">154</span>  <span class="py-line">    <span class="py-keyword">for</span> <span class="py-name">symb_in</span><span class="py-op">,</span> <span class="py-name">symb_out</span> <span class="py-keyword">in</span> <span id="link-20" class="py-name"><a title="pytils.translit.TRANSTABLE" class="py-name" href="#" onclick="doclink('link-20', 'TRANSTABLE', 'Variable pytils.translit.TRANSTABLE=pytils.translit-module.html#TRANSTABLE'); return false;">TRANSTABLE</a></span></span><span class="py-op">:</span> </span>
<span class="py-lineno">155</span>  <span class="py-line">        <span id="link-21" class="py-name"><a title="pytils.translit" class="py-name" href="#" onclick="doclink('link-21', 'translit', 'Module pytils.translit=pytils.translit-module.html'); return false;">translit</a></span></span> <span class="py-op">=</span> <span id="link-22" class="py-name"><a title="pytils.translit" class="py-name" href="#" onclick="doclink('link-22', 'translit', 'Module pytils.translit=pytils.translit-module.html'); return false;">translit</a></span></span><span class="py-op">.</span><span class="py-name">replace</span><span class="py-op">(</span><span class="py-name">symb_in</span><span class="py-op">,</span> <span class="py-name">symb_out</span><span class="py-op">)</span> </span>
<span class="py-lineno">156</span>  <span class="py-line"> </span>
<span class="py-lineno">157</span>  <span class="py-line">    <span class="py-keyword">try</span><span class="py-op">:</span> </span>
<span class="py-lineno">158</span>  <span class="py-line">        <span id="link-23" class="py-name"><a title="pytils.translit" class="py-name" href="#" onclick="doclink('link-23', 'translit', 'Module pytils.translit=pytils.translit-module.html'); return false;">translit</a></span></span> <span class="py-op">=</span> <span class="py-name">str</span><span class="py-op">(</span><span id="link-24" class="py-name"><a title="pytils.translit" class="py-name" href="#" onclick="doclink('link-24', 'translit', 'Module pytils.translit=pytils.translit-module.html'); return false;">translit</a></span></span><span class="py-op">)</span> </span>
<span class="py-lineno">159</span>  <span class="py-line">    <span class="py-keyword">except</span> <span class="py-name">UnicodeEncodeError</span><span class="py-op">:</span> </span>
<span class="py-lineno">160</span>  <span class="py-line">        <span class="py-keyword">raise</span> <span class="py-name">ValueError</span><span class="py-op">(</span><span class="py-string">"Unicode string doesn't transliterate completely, "</span> <span class="py-op">+</span> \ </span>
<span class="py-lineno">161</span>  <span class="py-line">                         <span class="py-string">"is it russian?"</span><span class="py-op">)</span> </span>
<span class="py-lineno">162</span>  <span class="py-line"> </span>
<span class="py-lineno">163</span>  <span class="py-line">    <span class="py-keyword">return</span> <span id="link-25" class="py-name"><a title="pytils.translit" class="py-name" href="#" onclick="doclink('link-25', 'translit', 'Module pytils.translit=pytils.translit-module.html'); return false;">translit</a></span></span> </span>
</div><span class="py-lineno">164</span>  <span class="py-line"> </span>
<a name="detranslify"></a><div id="detranslify-def"><span class="py-lineno">165</span> <a class="py-toggle" href="#" id="detranslify-toggle" onclick="toggle('detranslify'); return false;">-</a><span class="py-line"><span class="py-keyword">def</span> <a class="py-def-name" href="pytils.translit-module.html#detranslify">detranslify</a><span class="py-op">(</span><span class="py-param">in_string</span><span class="py-op">)</span><span class="py-op">:</span> </span>
</div><div id="detranslify-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="detranslify-expanded"><span class="py-lineno">166</span>  <span class="py-line">    <span class="py-docstring">"""</span> </span>
<span class="py-lineno">167</span>  <span class="py-line"><span class="py-docstring">    Detranslify</span> </span>
<span class="py-lineno">168</span>  <span class="py-line"><span class="py-docstring"></span> </span>
<span class="py-lineno">169</span>  <span class="py-line"><span class="py-docstring">    @param in_string: input string</span> </span>
<span class="py-lineno">170</span>  <span class="py-line"><span class="py-docstring">    @type in_string: C{basestring}</span> </span>
<span class="py-lineno">171</span>  <span class="py-line"><span class="py-docstring">    </span> </span>
<span class="py-lineno">172</span>  <span class="py-line"><span class="py-docstring">    @return: detransliterated string</span> </span>
<span class="py-lineno">173</span>  <span class="py-line"><span class="py-docstring">    @rtype: C{str}</span> </span>
<span class="py-lineno">174</span>  <span class="py-line"><span class="py-docstring"></span> </span>
<span class="py-lineno">175</span>  <span class="py-line"><span class="py-docstring">    @raise TypeError: when in_string neither C{str}, no C{unicode}</span> </span>
<span class="py-lineno">176</span>  <span class="py-line"><span class="py-docstring">    @raise ValueError: if in_string is C{str}, but it isn't ascii</span> </span>
<span class="py-lineno">177</span>  <span class="py-line"><span class="py-docstring">    """</span> </span>
<span class="py-lineno">178</span>  <span class="py-line">    <span id="link-26" class="py-name"><a title="pytils.utils" class="py-name" href="#" onclick="doclink('link-26', 'utils', 'Module pytils.utils=pytils.utils-module.html'); return false;">utils</a></span></span><span class="py-op">.</span><span id="link-27" class="py-name"><a title="pytils.utils.check_type" class="py-name" href="#" onclick="doclink('link-27', 'check_type', 'Function pytils.utils.check_type()=pytils.utils-module.html#check_type'); return false;">check_type</a></span></span><span class="py-op">(</span><span class="py-string">'in_string'</span><span class="py-op">,</span> <span class="py-name">basestring</span><span class="py-op">)</span> </span>
<span class="py-lineno">179</span>  <span class="py-line"> </span>
<span class="py-lineno">180</span>  <span class="py-line">    <span class="py-comment"># &#1074; unicode</span> </span>
<span class="py-lineno">181</span>  <span class="py-line"><span class="py-comment"></span>    <span class="py-keyword">try</span><span class="py-op">:</span> </span>
<span class="py-lineno">182</span>  <span class="py-line">        <span class="py-name">russian</span> <span class="py-op">=</span> <span class="py-name">unicode</span><span class="py-op">(</span><span class="py-name">in_string</span><span class="py-op">)</span> </span>
<span class="py-lineno">183</span>  <span class="py-line">    <span class="py-keyword">except</span> <span class="py-name">UnicodeDecodeError</span><span class="py-op">:</span> </span>
<span class="py-lineno">184</span>  <span class="py-line">        <span class="py-keyword">raise</span> <span class="py-name">ValueError</span><span class="py-op">(</span><span class="py-string">"We expects when in_string is str type,"</span> <span class="py-op">+</span> \ </span>
<span class="py-lineno">185</span>  <span class="py-line">                         <span class="py-string">"it is an ascii, but now it isn't. Use unicode "</span> <span class="py-op">+</span> \ </span>
<span class="py-lineno">186</span>  <span class="py-line">                         <span class="py-string">"in this case."</span><span class="py-op">)</span> </span>
<span class="py-lineno">187</span>  <span class="py-line"> </span>
<span class="py-lineno">188</span>  <span class="py-line">    <span class="py-keyword">for</span> <span class="py-name">symb_out</span><span class="py-op">,</span> <span class="py-name">symb_in</span> <span class="py-keyword">in</span> <span id="link-28" class="py-name"><a title="pytils.translit.TRANSTABLE" class="py-name" href="#" onclick="doclink('link-28', 'TRANSTABLE', 'Variable pytils.translit.TRANSTABLE=pytils.translit-module.html#TRANSTABLE'); return false;">TRANSTABLE</a></span></span><span class="py-op">:</span> </span>
<span class="py-lineno">189</span>  <span class="py-line">        <span class="py-name">russian</span> <span class="py-op">=</span> <span class="py-name">russian</span><span class="py-op">.</span><span class="py-name">replace</span><span class="py-op">(</span><span class="py-name">symb_in</span><span class="py-op">,</span> <span class="py-name">symb_out</span><span class="py-op">)</span> </span>
<span class="py-lineno">190</span>  <span class="py-line"> </span>
<span class="py-lineno">191</span>  <span class="py-line">    <span class="py-keyword">return</span> <span class="py-name">russian</span> </span>
</div><span class="py-lineno">192</span>  <span class="py-line"> </span>
<a name="slugify"></a><div id="slugify-def"><span class="py-lineno">193</span> <a class="py-toggle" href="#" id="slugify-toggle" onclick="toggle('slugify'); return false;">-</a><span class="py-line"><span class="py-keyword">def</span> <a class="py-def-name" href="pytils.translit-module.html#slugify">slugify</a><span class="py-op">(</span><span class="py-param">in_string</span><span class="py-op">)</span><span class="py-op">:</span> </span>
</div><div id="slugify-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="slugify-expanded"><span class="py-lineno">194</span>  <span class="py-line">    <span class="py-docstring">"""</span> </span>
<span class="py-lineno">195</span>  <span class="py-line"><span class="py-docstring">    Prepare string for slug (i.e. URL or file/dir name)</span> </span>
<span class="py-lineno">196</span>  <span class="py-line"><span class="py-docstring"></span> </span>
<span class="py-lineno">197</span>  <span class="py-line"><span class="py-docstring">    @param in_string: input string</span> </span>
<span class="py-lineno">198</span>  <span class="py-line"><span class="py-docstring">    @type in_string: C{basestring}</span> </span>
<span class="py-lineno">199</span>  <span class="py-line"><span class="py-docstring"></span> </span>
<span class="py-lineno">200</span>  <span class="py-line"><span class="py-docstring">    @return: slug-string</span> </span>
<span class="py-lineno">201</span>  <span class="py-line"><span class="py-docstring">    @rtype: C{str}</span> </span>
<span class="py-lineno">202</span>  <span class="py-line"><span class="py-docstring"></span> </span>
<span class="py-lineno">203</span>  <span class="py-line"><span class="py-docstring">    @raise TypeError: when in_string isn't C{unicode} or C{str}</span> </span>
<span class="py-lineno">204</span>  <span class="py-line"><span class="py-docstring">    @raise ValueError: if in_string is C{str}, but it isn't ascii</span> </span>
<span class="py-lineno">205</span>  <span class="py-line"><span class="py-docstring">    """</span> </span>
<span class="py-lineno">206</span>  <span class="py-line">    <span id="link-29" class="py-name"><a title="pytils.utils" class="py-name" href="#" onclick="doclink('link-29', 'utils', 'Module pytils.utils=pytils.utils-module.html'); return false;">utils</a></span></span><span class="py-op">.</span><span id="link-30" class="py-name"><a title="pytils.utils.check_type" class="py-name" href="#" onclick="doclink('link-30', 'check_type', 'Function pytils.utils.check_type()=pytils.utils-module.html#check_type'); return false;">check_type</a></span></span><span class="py-op">(</span><span class="py-string">'in_string'</span><span class="py-op">,</span> <span class="py-name">basestring</span><span class="py-op">)</span> </span>
<span class="py-lineno">207</span>  <span class="py-line">    <span class="py-keyword">try</span><span class="py-op">:</span> </span>
<span class="py-lineno">208</span>  <span class="py-line">        <span class="py-name">u_in_string</span> <span class="py-op">=</span> <span class="py-name">unicode</span><span class="py-op">(</span><span class="py-name">in_string</span><span class="py-op">)</span> </span>
<span class="py-lineno">209</span>  <span class="py-line">    <span class="py-keyword">except</span> <span class="py-name">UnicodeDecodeError</span><span class="py-op">:</span> </span>
<span class="py-lineno">210</span>  <span class="py-line">        <span class="py-keyword">raise</span> <span class="py-name">ValueError</span><span class="py-op">(</span><span class="py-string">"We expects when in_string is str type,"</span> <span class="py-op">+</span> \ </span>
<span class="py-lineno">211</span>  <span class="py-line">                         <span class="py-string">"it is an ascii, but now it isn't. Use unicode "</span> <span class="py-op">+</span> \ </span>
<span class="py-lineno">212</span>  <span class="py-line">                         <span class="py-string">"in this case."</span><span class="py-op">)</span> </span>
<span class="py-lineno">213</span>  <span class="py-line">     </span>
<span class="py-lineno">214</span>  <span class="py-line"> </span>
<span class="py-lineno">215</span>  <span class="py-line"> </span>
<span class="py-lineno">216</span>  <span class="py-line">    <span class="py-comment"># convert &amp; to "and"</span> </span>
<span class="py-lineno">217</span>  <span class="py-line"><span class="py-comment"></span>    <span class="py-name">u_in_string</span> <span class="py-op">=</span> <span class="py-name">re</span><span class="py-op">.</span><span class="py-name">sub</span><span class="py-op">(</span><span class="py-string">'\&amp;amp\;|\&amp;'</span><span class="py-op">,</span> <span class="py-string">' and '</span><span class="py-op">,</span> <span class="py-name">u_in_string</span><span class="py-op">)</span> </span>
<span class="py-lineno">218</span>  <span class="py-line">    <span class="py-comment"># replace spaces by hyphen</span> </span>
<span class="py-lineno">219</span>  <span class="py-line"><span class="py-comment"></span>    <span class="py-name">u_in_string</span> <span class="py-op">=</span> <span class="py-name">re</span><span class="py-op">.</span><span class="py-name">sub</span><span class="py-op">(</span><span class="py-string">'[-\s]+'</span><span class="py-op">,</span> <span class="py-string">'-'</span><span class="py-op">,</span> <span class="py-name">u_in_string</span><span class="py-op">)</span> </span>
<span class="py-lineno">220</span>  <span class="py-line">    <span class="py-comment"># remove symbols that not in alphabet</span> </span>
<span class="py-lineno">221</span>  <span class="py-line"><span class="py-comment"></span>    <span class="py-name">u_in_string</span> <span class="py-op">=</span> <span class="py-string">u''</span><span class="py-op">.</span><span class="py-name">join</span><span class="py-op">(</span><span class="py-op">[</span><span class="py-name">symb</span> <span class="py-keyword">for</span> <span class="py-name">symb</span>  <span class="py-keyword">in</span> <span class="py-name">u_in_string</span> <span class="py-keyword">if</span> <span class="py-name">symb</span> <span class="py-keyword">in</span> <span id="link-31" class="py-name"><a title="pytils.translit.ALPHABET" class="py-name" href="#" onclick="doclink('link-31', 'ALPHABET', 'Variable pytils.translit.ALPHABET=pytils.translit-module.html#ALPHABET'); return false;">ALPHABET</a></span></span><span class="py-op">]</span><span class="py-op">)</span> </span>
<span class="py-lineno">222</span>  <span class="py-line">    <span class="py-comment"># translify it</span> </span>
<span class="py-lineno">223</span>  <span class="py-line"><span class="py-comment"></span>    <span class="py-name">out_string</span> <span class="py-op">=</span> <span id="link-32" class="py-name"><a title="pytils.templatetags.pytils_translit.translify
pytils.translit.translify" class="py-name" href="#" onclick="doclink('link-32', 'translify', 'Function pytils.templatetags.pytils_translit.translify()=pytils.templatetags.pytils_translit-module.html#translify,Function pytils.translit.translify()=pytils.translit-module.html#translify'); return false;">translify</a></span></span><span class="py-op">(</span><span class="py-name">u_in_string</span><span class="py-op">)</span> </span>
<span class="py-lineno">224</span>  <span class="py-line">    <span class="py-comment"># remove non-alpha</span> </span>
<span class="py-lineno">225</span>  <span class="py-line"><span class="py-comment"></span>    <span class="py-keyword">return</span> <span class="py-name">re</span><span class="py-op">.</span><span class="py-name">sub</span><span class="py-op">(</span><span class="py-string">'[^\w\s-]'</span><span class="py-op">,</span> <span class="py-string">''</span><span class="py-op">,</span> <span class="py-name">out_string</span><span class="py-op">)</span><span class="py-op">.</span><span class="py-name">strip</span><span class="py-op">(</span><span class="py-op">)</span><span class="py-op">.</span><span class="py-name">lower</span><span class="py-op">(</span><span class="py-op">)</span> </span>
</div><span class="py-lineno">226</span>  <span class="py-line">         </span>
<a name="dirify"></a><div id="dirify-def"><span class="py-lineno">227</span> <a class="py-toggle" href="#" id="dirify-toggle" onclick="toggle('dirify'); return false;">-</a><span class="py-line"><span class="py-keyword">def</span> <a class="py-def-name" href="pytils.translit-module.html#dirify">dirify</a><span class="py-op">(</span><span class="py-param">in_string</span><span class="py-op">)</span><span class="py-op">:</span> </span>
</div><div id="dirify-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="dirify-expanded"><span class="py-lineno">228</span>  <span class="py-line">    <span class="py-docstring">"""</span> </span>
<span class="py-lineno">229</span>  <span class="py-line"><span class="py-docstring">    Alias for L{slugify}</span> </span>
<span class="py-lineno">230</span>  <span class="py-line"><span class="py-docstring">    """</span> </span>
<span class="py-lineno">231</span>  <span class="py-line">    <span id="link-33" class="py-name"><a title="pytils.templatetags.pytils_translit.slugify
pytils.translit.slugify" class="py-name" href="#" onclick="doclink('link-33', 'slugify', 'Function pytils.templatetags.pytils_translit.slugify()=pytils.templatetags.pytils_translit-module.html#slugify,Function pytils.translit.slugify()=pytils.translit-module.html#slugify'); return false;">slugify</a></span></span><span class="py-op">(</span><span class="py-name">in_string</span><span class="py-op">)</span> </span>
</div><span class="py-lineno">232</span>  <span class="py-line"> </span><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="pytils-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">Generated by Epydoc
        3.0alpha3 on Sun Oct 29 00:35:03 2006</td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>
